package service;//package service;
//
//import java.io.BufferedInputStream;
//import java.io.BufferedOutputStream;
//import java.io.BufferedReader;
//import java.io.File;
//import java.io.FileInputStream;
//import java.io.FileNotFoundException;
//import java.io.FileOutputStream;
//import java.io.FileReader;
//import java.io.FilterInputStream;
//import java.io.IOException;
//import java.io.InputStream;
//import java.io.InputStreamReader;
//import java.io.OutputStream;
//import java.io.OutputStreamWriter;
//import java.io.SequenceInputStream;
//import java.util.ArrayList;
//import java.util.Enumeration;
//import java.util.List;
//import java.util.zip.CRC32;
//import java.util.zip.CheckedOutputStream;
//import java.util.zip.Checksum;
////import javax.rmi.CORBA.Util;
////import java.util.zip.ZipEntry;
////import java.util.zip.ZipOutputStream;
//import org.apache.tools.zip.ZipEntry;
//import org.apache.tools.zip.ZipOutputStream;
//import org.apache.tools.zip.ZipFile;
//
//
//public class ZipCompress {
//    static final int BUFFER = 8192;
//    private File zipFile;
//
//    public ZipCompress(String pathName) {
//        zipFile = new File(pathName);
//    }
//
//    public void Compress(String srcPathName) {
//        File file = new File(srcPathName);
//        if (!file.exists()) {
//            throw new RuntimeException(srcPathName +"不存在");
//        }
//        try {
//            FileOutputStream fos = new FileOutputStream(zipFile);
//            CheckedOutputStream cos = new CheckedOutputStream(fos, new CRC32());
//            ZipOutputStream zos =new ZipOutputStream(cos);
//            String basedir ="";
//            Compress(file, zos, basedir);
//            zos.close();
//        } catch (Exception e) {
//            throw new RuntimeException(e);
//        }
//    }
//
//    private void Compress(File file, ZipOutputStream zos, String basedir) {
//        if (file.isDirectory()) {
//            System.out.println("压缩"+ basedir + file.getName()+"成功");
//            this.CompressDirectory(file, zos, basedir);
//        } else {
//            System.out.println("压缩"+ basedir + file.getName()+"成功");
//            this.CompressFile(file, zos, basedir);
//        }
//    }
//
//    private void CompressDirectory(File dir, ZipOutputStream zos, String basedir) {
//        if (!dir.exists()) {
//            return;
//        }
//        File[] files = dir.listFiles();
//        for (int i = 0; i < files[i].length(); i++) {
//            Compress(files[i], zos, basedir + dir.getName() +"/");
//        }
//    }
//
//    private void CompressFile(File file, ZipOutputStream out, String basedir) {
//        if (!file.exists()) {
//            return;
//        }
//        try {
//            BufferedInputStream bis = new BufferedInputStream(new FileInputStream(file));
//            ZipEntry ze = new ZipEntry(basedir + file.getName());
//            out.putNextEntry(ze);
//            int count;
//            byte[] data = new byte[BUFFER];
//            while ((count = bis.read(data, 0, BUFFER)) != -1) {
//                out.write(data, 0, BUFFER);
//            }
//            bis.close();
//        } catch (Exception e) {
//            throw new RuntimeException(e);
//        }
//    }
//
//    public static void main(String args[]) {
//        ZipCompress zc = new ZipCompress("d:/java.zip");
//        zc.Compress("e:/");
//        System.out.println("OK/......");
//    }
//}